package org.example.SlApi.MctjApi;





import io.restassured.RestAssured;
import io.restassured.response.Response;
import org.example.utils.ReadConf;

import java.io.UnsupportedEncodingException;
import java.util.HashMap;
import java.util.Map;

import static org.example.CookieHandlingFilter.cookies;
import static org.example.RestClient.givenWithCookies;
import static org.example.RestClient.loginAndUpdateCookies;


public class McccApi {
    public static Map<String, String> loginAndUpdateCookies;

    public static void main(String[] args) throws UnsupportedEncodingException {    //企业开办
        McccApi();
    }
    public static int McccApi() throws UnsupportedEncodingException {
        // 登录并更新cookies

        loginAndUpdateCookies();

        RestAssured.baseURI = ReadConf.getHost(); // 设置基础URI

        Map<String, String> formParams = new HashMap<>();
        formParams.put("method", "enterMczzcc");
        formParams.put("sbms", "1");
        formParams.put("qylx", "qy");


        Response response = givenWithCookies()


//               .cookies(cookies)
                .params(formParams)

                .post("ywtSldj.do?method=enterMczzcc&sbms=1&qylx=qy&fromSign=&csrftoken="); // 注意：可能需要有效的 CSRF Token
        System.out.println(cookies);
        int statusCode = Integer.parseInt(String.valueOf(response.getStatusCode()));
        Map<String, String> cookies = response.getCookies();
        System.out.println(statusCode);
        String body = response.getBody().asString();
//        System.out.println(body);


        return statusCode;
    }

    }



